package com.iflytek.autofly.setting.util;

import com.iflytek.autofly.audioservice.util.AudioServiceCons.ErrorCode;

/**
 * <b>Description: </b>FlyPlatfromUtil<br/>
 * <b>Change History:</b><br/>
 * <table border="1">
 * <tr>
 * <td><b>user</b></td>
 * <td><b>date</b></td>
 * <td><b>time</b></td>
 * <td><b>reason</b></td>
 * </tr>
 * <tr>
 * <td>JunLuan@iflytek.com</td>
 * <td>2015/11/3</td>
 * <td>11:14</td>
 * <td>创建此文件</td>
 * </tr>
 * </table>
 *
 * @author JunLuan@iflytek.com
 */
public class FlyPlatfromUtil {
    static public String error(int retCode) {

        // 从源码里把错误码copy到notepad++之类的
        // 正则表达式替换 (.*)\s=.* 为
        // case ErrorCode.\1: return "\1\("+ErrorCode.\1+"\)";
        switch (retCode) {
            case ErrorCode.ERROR_OK:
                return "ERROR_OK(" + ErrorCode.ERROR_OK + ")";
            case ErrorCode.ERROR_BASE:
                return "ERROR_BASE(" + ErrorCode.ERROR_BASE + ")";
            case ErrorCode.ERROR_PARAM_OUTOFBOUND:
                return "ERROR_PARAM_OUTOFBOUND(" + ErrorCode.ERROR_PARAM_OUTOFBOUND + ")";
            case ErrorCode.ERROR_PARAM_NULL:
                return "ERROR_PARAM_NULL(" + ErrorCode.ERROR_PARAM_NULL + ")";
            case ErrorCode.ERROR_COMMON:
                return "ERROR_COMMON(" + ErrorCode.ERROR_COMMON + ")";
            case ErrorCode.ERROR_AIDL_BINDING:
                return "ERROR_AIDL_BINDING(" + ErrorCode.ERROR_AIDL_BINDING + ")";
            case ErrorCode.ERROR_AIDL_NOT_BOUND:
                return "ERROR_AIDL_NOT_BOUND(" + ErrorCode.ERROR_AIDL_NOT_BOUND + ")";
            case ErrorCode.ERROR_AIDL_NO_SERVICE:
                return "ERROR_AIDL_NO_SERVICE(" + ErrorCode.ERROR_AIDL_NO_SERVICE + ")";
            case ErrorCode.ERROR_REBUNDANCE_LISTENER:
                return "ERROR_REBUNDANCE_LISTENER(" + ErrorCode.ERROR_REBUNDANCE_LISTENER + ")";
            case ErrorCode.ERROR_VCARD_PROCESSING:
                return "ERROR_VCARD_PROCESSING(" + ErrorCode.ERROR_VCARD_PROCESSING + ")";
            case ErrorCode.ERROR_INVALID_ARG_VALUE:
                return "ERROR_INVALID_ARG_VALUE(" + ErrorCode.ERROR_INVALID_ARG_VALUE + ")";
            case ErrorCode.ERROR_SERVICE_NULL:
                return "ERROR_SERVICE_NULL(" + ErrorCode.ERROR_SERVICE_NULL + ")";
            case ErrorCode.ERROR_NULL:
                return "ERROR_NULL(" + ErrorCode.ERROR_NULL + ")";
            case ErrorCode.ERROR_MICCONTROL_CHANGE:
                return "ERROR_MICCONTROL_CHANGE(" + ErrorCode.ERROR_MICCONTROL_CHANGE + ")";
            case ErrorCode.ERROR_MICCONTROL_DEVICE:
                return "ERROR_MICCONTROL_DEVICE(" + ErrorCode.ERROR_MICCONTROL_DEVICE + ")";
            case ErrorCode.ERROR_NOT_SUPPORT:
                return "ERROR_NOT_SUPPORT(" + ErrorCode.ERROR_NOT_SUPPORT + ")";
            case ErrorCode.ERROR_REMOTEEXCEPTION:
                return "ERROR_REMOTEEXCEPTION(" + ErrorCode.ERROR_REMOTEEXCEPTION + ")";
            case ErrorCode.ERROR_SERVICE_RETURE:
                return "ERROR_SERVICE_RETURE(" + ErrorCode.ERROR_SERVICE_RETURE + ")";
            case ErrorCode.ERROR_PLATFORM_OBJ_NULL:
                return "ERROR_PLATFORM_OBJ_NULL(" + ErrorCode.ERROR_PLATFORM_OBJ_NULL + ")";
            case ErrorCode.ERROR_END:
                return "ERROR_END(" + ErrorCode.ERROR_END + ")";
            default:
        }
        return "UNKNOWN_ERROR(" + retCode + ")";
    }

    public static boolean isError(int retCode) {
        // 从源码里把错误码copy到notepad++之类的
        // 正则表达式替换 (.*)\s=.* 为
        // case ErrorCode.\1:;
        switch (retCode) {
            case ErrorCode.ERROR_BASE:
            case ErrorCode.ERROR_PARAM_OUTOFBOUND:
            case ErrorCode.ERROR_PARAM_NULL:
            case ErrorCode.ERROR_COMMON:
            case ErrorCode.ERROR_AIDL_BINDING:
            case ErrorCode.ERROR_AIDL_NOT_BOUND:
            case ErrorCode.ERROR_AIDL_NO_SERVICE:
            case ErrorCode.ERROR_REBUNDANCE_LISTENER:
            case ErrorCode.ERROR_VCARD_PROCESSING:
            case ErrorCode.ERROR_INVALID_ARG_VALUE:
            case ErrorCode.ERROR_SERVICE_NULL:
            case ErrorCode.ERROR_NULL:
            case ErrorCode.ERROR_MICCONTROL_CHANGE:
            case ErrorCode.ERROR_MICCONTROL_DEVICE:
            case ErrorCode.ERROR_NOT_SUPPORT:
            case ErrorCode.ERROR_REMOTEEXCEPTION:
            case ErrorCode.ERROR_SERVICE_RETURE:
            case ErrorCode.ERROR_PLATFORM_OBJ_NULL:
            case ErrorCode.ERROR_END:
                return true;
            default:
        }
        return false;

    }


}
